import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

/**
 * This code was edited or generated using CloudGarden's Jigloo
 * SWT/Swing GUI Builder, which is free for non-commercial
 * use. If Jigloo is being used commercially (ie, by a corporation,
 * company or business for any purpose whatever) then you
 * should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details.
 * Use of Jigloo implies acceptance of these licensing terms.
 * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
 * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
 * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class MainFrame extends javax.swing.JFrame {
	private UserInterface ui;
	public JPanel jPanel1;
	public JLabel foodlabel;
	public JLabel stonelabel;
	private JButton sendbutton;
	private JTextField chatinput;
	public JTextPane chatpane;
	public JLabel reedlabel;
	public JLabel claylabel;
	public JLabel woodlabel;
	private JButton endturnbutton;
	private JButton takefoodbutton;

	public MainFrame(String s, UserInterface u) {
		super(s);
		ui = u;
		initGUI();
	}

	private void initGUI() {
		{
			jPanel1 = new JPanel();
			getContentPane().add(jPanel1, BorderLayout.CENTER);
			jPanel1.setLayout(null);
			{
				endturnbutton = new JButton();
				jPanel1.add(endturnbutton);
				endturnbutton.setText("End Turn");
				endturnbutton.setBounds(255, 232, 148, 22);
				endturnbutton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
					}
				});
			}
			{
				foodlabel = new JLabel();
				jPanel1.add(foodlabel);
				foodlabel.setText("Food: ");
				foodlabel.setBounds(638, 386, 135, 16);
			}
			{
				takefoodbutton = new JButton();
				jPanel1.add(takefoodbutton);
				takefoodbutton.setText("Take Food");
				takefoodbutton.setBounds(255, 199, 148, 22);
				takefoodbutton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						//do action 0
						Client.c.sendMessage(new Message(Message.ACTION, 0));
						//ui.update();
					}
				});
			}
			{
				woodlabel = new JLabel();
				jPanel1.add(woodlabel);
				woodlabel.setText("Wood:");
				woodlabel.setBounds(638, 411, 135, 16);
			}
			{
				claylabel = new JLabel();
				jPanel1.add(claylabel);
				claylabel.setText("Clay:");
				claylabel.setBounds(638, 436, 135, 16);
			}
			{
				reedlabel = new JLabel();
				jPanel1.add(reedlabel);
				reedlabel.setText("Reed:");
				reedlabel.setBounds(638, 461, 135, 16);
			}
			{
				stonelabel = new JLabel();
				jPanel1.add(stonelabel);
				stonelabel.setText("Stone:");
				stonelabel.setBounds(638, 486, 135, 16);
			}
			{
				chatpane = new JTextPane();
				jPanel1.add(chatpane);
				chatpane.setContentType("text/html");
				chatpane.setText("Chat");
				chatpane.setBounds(804, 12, 291, 503);
				chatpane.setEditable(false);
				chatpane.setOpaque(false);
			}
			{
				chatinput = new JTextField();
				jPanel1.add(chatinput);
				chatinput.setBounds(804, 527, 233, 22);
				chatinput.addKeyListener(new KeyAdapter() {
					public void keyTyped(KeyEvent e) {
						if(e.getKeyChar() == '\n') {
							sendbutton.doClick();
						}
					}
				});
			}
			{
				sendbutton = new JButton();
				jPanel1.add(sendbutton);
				sendbutton.setText("Send");
				sendbutton.setBounds(1037, 527, 59, 22);
				sendbutton.setFont(new java.awt.Font("Arial",0,10));
				sendbutton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						Client.Communication.tosend.add(new Message(Message.CHAT,chatinput.getText()));
						ui.update();
						chatinput.setText("");
					}
				});
			}
		}

		this.setSize(1123, 596);
	}

}
